package main.ObjectIO;

import java.io.*;

public class ObjectInOut {
    public static void main(String[] args) {
        try{
            //ObOut();
            ObIn();
        }catch (Exception e){
            e.printStackTrace();
        }

    }
    public static void ObOut() throws IOException {
        ObjectOutputStream oOut = new ObjectOutputStream(new FileOutputStream("data//rrOut.txt"));
        Person p = new Person();
        p.age = 11;
        p.name = "minangong";
        oOut.writeObject(p);
        oOut.flush();
        oOut.close();
    }
    public static void ObIn() throws Exception {
        ObjectInputStream oIn = new ObjectInputStream(new FileInputStream("data//rrOut.txt"));
        Object o = oIn.readObject();
        Person p = (Person)o;
        System.out.println(p.name);
        System.out.println(p.age);
        oIn.close();
    }

}
